package de.mmbbs;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

public class LandingPad extends Basic2dObject {
	
	public LandingPad(Context context){
		Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.platform);
		super.setBitmap(bitmap);
	}

	@Override
	public void paint(Canvas canvas) {
		
		super.setPosition(canvas.getWidth()/2 - (super.getWidth()/2), (canvas.getHeight() - (super.getHeight() + 15)));
		super.paint(canvas);
	}
	
	public boolean isShipLanded(Ship ship){
		
		int goal = this.getWidth() - ship.getWidth();
		boolean landed = false;
		
		if((ship.getPositionX() > goal - 5) && (ship.getPositionX() < goal + 5)){
			if ( ship.getPositionY() + ship.getHeight() == this.getPositionY()){
				landed = true;
			}
		} 
		
		return landed;
	}
}
